<template>
  <el-dialog
    class="dialog"
    width="603px"
    center
    title="编辑学科"
    :visible.sync="visible"
    :close-on-click-modal="false"
  >
    <el-form status-icon :model="form" label-width="80px">
      <el-form-item label="学科编号">
        <el-input v-model="form.rid" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="学科名称">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="学科简称">
        <el-input v-model="form.short_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="学科简介">
        <el-input v-model="form.intro" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="学科备注">
        <el-input v-model="form.remark" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="subjectEdit">更新</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { subjectEdit } from '@/api/subject.js'

export default {
  data () {
    return {
      visible: false,
      form: {
        rid: '',
        name: '',
        short_name: '',
        intro: '',
        remark: ''
      }
    }
  },
  methods: {
    // 新增
    subjectEdit () {
      subjectEdit(this.form).then(() => {
        this.$parent.querySubjectList()
        this.$message.success('编辑成功')
      })
      this.visible = false
    }
  }
}
</script>

<style lang="less">
.dialog {
  .el-dialog__header {
    background: linear-gradient(to right, #0dbfef, #1792f8);
  }
  .el-dialog__title {
    color: white;
  }
}
</style>
